1. Field of the Invention
The invention relates to a method for detecting video frame types with adaptive thresholds that determines whether a video frame is an interlaced frame or a progressive frame by using adaptive thresholds to avoid incorrect judgement of the frame type resulting from excessive field difference and improve detection accuracy.
2. Description of the Prior Art
The video picture that is commonly adopted at present is transmitted at thirty frames per second to produce continuous and dynamic images. Each frame consists of a plurality of scan lines (for instance, National Television System Committee—NTSC, standard is 525 scan lines). That is, 525 scan lines are transmitted in 1/30 second for one frame.
Said video frame can be classified into two categories: interlaced frame and progressive frame. Scanning of the interlaced frame is divided in a top-field and a bottom-field. The top-field has an odd number of scan lines while the bottom-field has an even number of scan lines. They are scanned separately at two times. For instance, the top-field is scanned first, then the bottom-field is scanned to generate a complete frame. On the other hand, all of the scanning lines of the progressive frame are transmitted at the same time, then are scanned individually one by one.
Refer to FIGS. 1(a) and 1(b) for an interlaced frame 10 and a progressive frame 11. As the interlaced frame 10 is scanned at different times and is transmitted respectively for the top-field (odd number of scan lines) and the bottom-field (even number of scan lines), a comb-shaped pattern is generated on the peripheral edges of the square picture 100 and the triangle picture 101 (generally called comb factor). The resolution is less desirable and video quality is poorer. On the other hand, the whole progressive frame 11 is transmitted at the same time, therefore the comb factor does not occur as shown in FIG. 1(a).
Based on previous discussion, it is obvious that the comb factor has great impact on resolution. Hence prior to video output, a detection process is performed to determine whether the input frame is an interlaced frame or a progressive frame. If the interlaced frame is detected, then a deinterlacing process is executed to remove the comb factor to obtain a higher quality video. If the progressive frame is detected, the video may be directly output without deinterlacing.
Refer to FIG. 2 for a conventional detection process. First, at step 201, set the comb factor counter to zero and input a frame F (n) at time instance “n” for calculating the comb factor of pixels; next, at step 202, transfer all of the pixels into the frame function F (n); at step 203, scan pixels in the raster order and calculate the comb factor of the pixels (the equation for calculating the comb factor will be discussed later); at step 204, determine whether the comb factor at each pixel is greater than the threshold value, if “yes”, proceed step 205 and increase the value of comb factor counter by one; if “no”, proceed step 206 to determine if it is the last pixel in the frame; if it is the last pixel, proceed step 207; if “no”, repeat step 203 through step 206; at step 207, determine whether the value in the comb factor counter is smaller than a threshold value, if yes, the frame is judged as a progressive frame at step 208; if no (i.e. the counter value is greater than the threshold value), proceed step 209 and judge the frame as an interlaced frame; finally end the detection process for frame F(n).
FIG. 3 illustrates the calculation of a pixel comb factor at step 203 shown in FIG. 2. The pixel 30 to be calculated is located at the coordinate (x,y) and denoted as X in the picture. O-31 indicates a first adjacent pixel “b” and O-32 indicates a second adjacent pixel “e”, then the equation for calculating the comb factor of the pixel 30 is as follows:Comb Factor (x,y)=(b−x)×(e−x)−(b−e)2
Although the equation set forth above may be used to calculate the value of the comb factor for every pixel, and the comb factor value may be compared with a set constant threshold value to determine whether the pixel is a comb factor, then the frame type may be determined based on the total number of the comb factor pixels (i.e. the counter number). Such a method still may result in incorrect judgement. It is because the number of the comb factor is proportional to the difference of the top-field and the bottom-field. The proportional relationship of the difference is illustrated in FIG. 4. It is substantially a linear direct proportion. In other words, if an interlaced frame contains objects of a slow motion or a lower frequency, the field difference would also be small and the comb factor number also would be small. However, if video content is more complex, such as including complicated objects like leaves or stones, even if there is no time difference between the top-field and the bottom-field (i.e. progressive frame), the calculated comb factor number could be relatively large. Therefore to determine the frame type based on merely one constant threshold value could mistakenly treat an interlaced frame of a slow motion or a low frequency as a progressive frame; or mistakenly treat a progressive frame of a fast motion or a high frequency as an interlaced frame. As a result, the interlaced frame could be output without undergoing the deinterlacing process and video output quality may suffer.